package edu.hbsi.demo2;
// Mammal接口定义
interface Mammal {
    void move();
}

// Cat类实现Mammal接口
class Cat implements Mammal {
    String name;
    String color;
    double weight;

    // 构造方法
    public Cat(String name, String color, double weight) {
        this.name = name;
        this.color = color;
        this.weight = weight;
    }
    // 实现move方法
    @Override
    public void move() {
        System.out.println("这只猫跳过了围栏");
    }

    // 展示猫的信息
    public void showInfo() {
        System.out.println("猫的名字：" + name + "，颜色：" + color + "，体重：" + weight + "kg");
    }
}

public class TestCat {

    // 数组排序方法
    public static void arraySort(double[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    // 交换元素
                    double temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
        // 输出排序后的数组
        for (double num : array) {
            System.out.print(num + " ");
        }
        System.out.println();
    }

    public static void main(String[] args) {
        // 创建Cat实例
        Cat cat1 = new Cat("汤姆", "黑色", 4.5);
        // 调用方法
        cat1.move();
        cat1.showInfo();

        // 定义数组并排序
        double[] myArray = {25, 32, 85, 78.5, 96.3, 45.2, 77.2, 65.3};
        arraySort(myArray);
    }
}
